<template>
  <el-container direction="vertical">
    <el-table
      :data="tableData"
      border
      style="width: 100%"
      size="mini">
      <el-table-column
        prop="id"
        label="ID"
        min-width="15%">
      </el-table-column>
      <el-table-column
        prop="versionByName"
        label="贡献人"
        min-width="10%">
      </el-table-column>
      <el-table-column
        prop="content"
        label="更新内容"
        min-width="30%">
      </el-table-column>
      <el-table-column
        prop="version"
        label="版本号"
        min-width="10%">
      </el-table-column>
      <el-table-column
        prop="createdTime"
        label="通过时间"
        min-width="10%">
      </el-table-column>
      <el-table-column
        fixed="right"
        label="操作"
        min-width="20%">
        <template slot-scope="scope">
          <el-button @click="detail(scope.row)" type="text" size="small">查看</el-button>
          <el-button type="text" @click="update(scope.row)" size="small">更新</el-button>
          <el-button type="text" @click="deleteOrg(scope.row)" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      style="text-align: center; padding: 10px 10px 5px 10px;"
      :current-page="pageData.current"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :page-size="pageData.size"
      layout="total, prev, pager, next, jumper"
      :total="total"
    />
  </el-container>
</template>

<script>
  export default {
    name: 'index',
    data: function() {
      return {
        tableData: [],
        pageData: {
          current: 1,
          size: 10,
        },
        total: 0,
        fileId: null,
      }
    },
    created() {
      this.fileId = this.$route.params.fileId;
      if (this.fileId == null || this.fileId == undefined) {
        this.$router.push({name: "FilePage"})
      }
      // this.fileId = '1238724675123191810';
      this.search();
    },
    methods: {
      handleSizeChange(val) {
        this.pageData.size = val;
      },
      handleCurrentChange(val) {
        this.pageData.current = val;
      },
      search() {
        let data = {...this.pageData};
        data['fileId'] = this.fileId;
        this.$api.fileVersionPage(data).then(res => {
          this.tableData = res.records;
        })
      }
    }
  }
</script>

<style scoped>

</style>
